home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / demos / OpenGL / fadeflip / myimage.h < prev    next >
C/C++ Source or Header  |  1996-11-11  |  4KB  |  118 lines

  1. /*
  2.  * (c) Copyright 1993, 1994, Silicon Graphics, Inc.
  3.  * ALL RIGHTS RESERVED
  4.  *
  5.  * Permission to use, copy, modify, and distribute this software for
  6.  * any purpose and without fee is hereby granted, provided that the above
  7.  * copyright notice appear in all copies and that both the copyright notice
  8.  * and this permission notice appear in supporting documentation, and that
  9.  * the name of Silicon Graphics, Inc. not be used in advertising
  10.  * or publicity pertaining to distribution of the software without specific,
  11.  * written prior permission.
  12.  *
  13.  * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS"
  14.  * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE,
  15.  * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR
  16.  * FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL SILICON
  17.  * GRAPHICS, INC.  BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT,
  18.  * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY
  19.  * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION,
  20.  * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF
  21.  * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC.  HAS BEEN
  22.  * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON
  23.  * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE
  24.  * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE.
  25.  *
  26.  * U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND
  27.  * Use, duplication, or disclosure by the Government is subject to
  28.  * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph
  29.  * (c)(1)(ii) of the Rights in Technical Data and Computer Software
  30.  * clause at DFARS 252.227-7013 and/or in similar or successor
  31.  * clauses in the FAR or the DOD or NASA FAR Supplement.
  32.  * Unpublished-- rights reserved under the copyright laws of the
  33.  * United States.  Contractor/manufacturer is Silicon Graphics,
  34.  * Inc., 2011 N.  Shoreline Blvd., Mountain View, CA 94039-7311.
  35.  *
  36.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  37.  */
  38. #ifndef    __GL_IMAGE_H__
  39. #define    __GL_IMAGE_H__
  40. /*
  41.  *    Defines for image files . . . .
  42.  *
  43.  *              Paul Haeberli - 1984
  44.  *      Look in /usr/people/4Dgifts/iristools/imgtools for example code!
  45.  *
  46.  */
  47.  
  48. #include <stdio.h>
  49.  
  50. #define IMAGIC     0732
  51.  
  52. /* colormap of images */
  53. #define CM_NORMAL        0    /* file contains rows of values which 
  54.                      * are either RGB values (zsize == 3) 
  55.                      * or greyramp values (zsize == 1) */
  56. #define CM_DITHERED        1
  57. #define CM_SCREEN        2    /* file contains data which is a screen
  58.                      * image; getrow returns buffer which 
  59.                      * can be displayed directly with 
  60.                      * writepixels */
  61. #define CM_COLORMAP        3    /* a colormap file */
  62.  
  63. #define TYPEMASK        0xff00
  64. #define BPPMASK            0x00ff
  65. #define ITYPE_VERBATIM        0x0000
  66. #define ITYPE_RLE        0x0100
  67. #define ISRLE(type)        (((type) & 0xff00) == ITYPE_RLE)
  68. #define ISVERBATIM(type)    (((type) & 0xff00) == ITYPE_VERBATIM)
  69. #define BPP(type)        ((type) & BPPMASK)
  70. #define RLE(bpp)        (ITYPE_RLE | (bpp))
  71. #define VERBATIM(bpp)        (ITYPE_VERBATIM | (bpp))
  72. #define    IBUFSIZE(pixels)    ((pixels+(pixels>>6))<<2)
  73. #define    RLE_NOP            0x00
  74.  
  75. #define    ierror(p)        (((p)->flags&_IOERR)!=0)
  76. #define    ifileno(p)        ((p)->file)
  77. #define    getpix(p)        (--(p)->cnt>=0 ? *(p)->ptr++ : ifilbuf(p))
  78. #define putpix(p,x)        (--(p)->cnt>=0 \
  79.                     ? ((int)(*(p)->ptr++=(unsigned)(x))) \
  80.                     : iflsbuf(p,(unsigned)(x)))
  81.  
  82. typedef struct {
  83.     unsigned short    imagic;        /* stuff saved on disk . . */
  84.     unsigned short     type;
  85.     unsigned short     dim;
  86.     unsigned short     xsize;
  87.     unsigned short     ysize;
  88.     unsigned short     zsize;
  89.     unsigned long     min;
  90.     unsigned long     max;
  91.     unsigned long    wastebytes;    
  92.     char         name[80];
  93.     unsigned long    colormap;
  94.  
  95.     long         file;        /* stuff used in core only */
  96.     unsigned short     flags;
  97.     short        dorev;
  98.     short        x;
  99.     short        y;
  100.     short        z;
  101.     short        cnt;
  102.     unsigned short    *ptr;
  103.     unsigned short    *base;
  104.     unsigned short    *tmpbuf;
  105.     unsigned long    offset;
  106.     unsigned long    rleend;        /* for rle images */
  107.     unsigned long    *rowstart;    /* for rle images */
  108.     long        *rowsize;    /* for rle images */
  109. } IMAGE;
  110.  
  111. void getrow(IMAGE *, unsigned short *, int, int);
  112. IMAGE *iopen(char *, char *);
  113. IMAGE *icreate();
  114. unsigned short *ibufalloc();
  115.  
  116. #define IMAGEDEF        /* for backwards compatibility */
  117. #endif    /* !__GL_IMAGE_H__ */
  118.